package Model;

import java.io.Serializable;

import Messaging.Notification;
import Messaging.NotificationManager;

/*
 * @author Roch San Buenaventura
 */

public class PropertyOwned extends SpaceState implements Serializable 
{
	
	final static long serialVersionUID = 213;
	
	private static PropertyOwned INSTANCE = null;
	
	protected PropertyOwned() 
	{
	
	}
	
	public static SpaceState Instance() 
	{
		if (INSTANCE == null) {
			INSTANCE = new PropertyOwned();
		}
		
		return INSTANCE;
	}
	
	public void landOn(Player player, PropertySpace property)
	{
		property.getOwner().collectRent(property.getRentValues()[0], player);
	}
	
	protected void renovate(UpgradeablePropertySpace p) 
	{
		p.changeState(UpgradeablePropertyLevel1.Instance());
		NotificationManager.getInstance().notifyObservers
		(Notification.UPDATE_PROPERTIES, new Player(p.getOwner()));
	}
	
	protected void downgrade(UpgradeablePropertySpace p) 
	{
		System.err.println("Attempted to downgrade PropertyOwned state");
	}

	protected boolean isUpgradeable(UpgradeablePropertySpace p)
	{
		return p.getOwner().monopolyUpgradeValid(p);
	}
	
	protected boolean isRenovated(UpgradeablePropertySpace p) 
	{
		return p.getOwner().propertiesRenovated(p.getTypeInt());
	}

	protected void ownershipIncrease(PropertySpace p)
	{
		p.changeState(PropertyOwns2.Instance());
	}
	
	protected void ownershipDecrease(PropertySpace p)
	{
		System.err.println("PropertyOwned ownershipDecrease called - Can't decrease ownership any more");
	}
	
	public String toString() 
	{
		return "PropertyOwned";
	}
}
